Repository navigation
Conversation
ry2009
commented
Dec 9, 2025
- Per-session agent/model prefs are persisted and re-applied on every switch (old and new sessions).
- Prefs are saved when leaving a session and applied (or seeded) when entering the next session.
- New pref store file session-pref.json under state dir; unit test for round-trip.
|
I know this still may be in talks about approach/want of this feature but thought I would get ahead as I saw it as low hanging fruit |
|
/review |
|
Yea |
| const pref = iife(() => { | ||
| const [store, setStore] = createStore<Record<string, SessionPref>>({}) | ||
|
|
||
| readPrefs() | ||
| .then((data) => { | ||
| setStore(() => data) | ||
| }) | ||
| .catch(() => {}) | ||
|
|
||
| function snapshot() { | ||
| return JSON.parse(JSON.stringify(store)) as Record<string, SessionPref> | ||
| } | ||
|
|
||
| function setSession(sessionID: string, value: SessionPref) { | ||
| setStore(sessionID, value) | ||
| writePrefs(snapshot()) | ||
| } | ||
|
|
There was a problem hiding this comment.
Okay why are we doing all this complex logic? Why don't we just read the last message and set the agent / model to what was set on the last message?
This seems wayyy overcomplicated
There was a problem hiding this comment.
This became a nuance in testing which lead to this, if user never sends a message (which I did not while switching multiple times) it fails -- also a little weird with how if multiple messages from different agents/models exist or which one is “current”? (slightly trivial problem though but the complex code goes around it totally)
I did not test this theory but this would require always scanning message history on every switch which for larger sessions or multiple large sessions (which I have seen in issues) could slow system down
Nonetheless I can attempt to simplify the pref module (drop snapshot(), use direct writes of the store object) without losing correctness if thats preffered?
There was a problem hiding this comment.
we only grab last 100 messages for rendering, you should be able to just messages[messages.length-1]
then grab agent and model from that
There was a problem hiding this comment.
if user hasnt sent message in a session use existing logic only change model/agent if the last message has a different one set and only run this on session switch
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |